window.onload = function () {
    let loginForm = document.querySelector(".login");
    let username = document.querySelector("#username");
    let password = document.querySelector("#password");

    console.log(username.innerText);
    loginForm.onsubmit = function (e) {
        e = e || window.event;
        e.returnValue = false;

        
        let p = pAjax({
            url: "/dl/login.php",
            type: "post",
            data: {
                username: username.value,
                password: password.value,
            },
        });
        p.then( function (res) {
                res = JSON.parse(res);
                console.log(res);
                
                if (res.code == 1) {
                    location.href = "../html/index.html";
                } else {
                    alert('你输入的账号不对呀，没有账号就注册一个吧==！')
                }
            });
    };
};
